package demo2;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lyw
 * Date: 2025-03-18
 * Time: 21:23
 */

public class Test {
    public static void mysort(Comparable[] comparables){
        for (int i = 0; i < comparables.length - 1; i++) {
            for (int j = 0; j < comparables.length - 1 - i; j++) {
                if(comparables[j].compareTo(comparables[j + 1]) > 0){
                    Comparable tmp = comparables[j];
                    comparables[j] = comparables[j + 1];
                    comparables[j + 1] = tmp;
                }
            }
        }
    }
    public static void main(String[] args) {
        /*Student student1 = new Student("张三",18);
        Student student2 = new Student("李四",19);
        System.out.println(student1.compareTo(student2));*/
        Student[] students = new Student[3];
        students[0] = new Student("zhangsan",18);
        students[1] = new Student("lisi",20);
        students[2] = new Student("wangwu",11);
        System.out.println("排序前：" + Arrays.toString(students));
        //Arrays.sort(students);
        mysort(students);
        System.out.println("排序后：" + Arrays.toString(students));

    }
}
